package com.koron.css2.clientCenter.impl;

import com.koron.css2.clientCenter.bean.AccountFlowListBean;
import com.koron.css2.clientCenter.mapper.UserInfoMapper;
import com.koron.css2.clientCenter.queryBean.UserChangeQueryBean;
import com.koron.css2.common.dto.AttachmentDto;
import com.koron.css2.common.service.AbstractExportExcel;
import com.koron.css2.serviceManage.bean.RequestBean;
import com.koron.css2.serviceManage.bean.UserInfoBean;
import com.koron.css2.serviceManage.utils.CommonUtils;
import com.koron.css2.serviceManage.utils.JsonUtils;
import com.koron.util.Tools;
import org.koron.ebs.mybatis.SessionFactory;

import java.util.List;
import java.util.Map;
/**
 * 账户流水导出
 * @author 甄玉晴
 *
 */
public class AccountFlowListExport extends AbstractExportExcel {

	@Override
	public AttachmentDto getAttachment(SessionFactory factory, UserInfoBean userInfo, RequestBean req)  {
		UserChangeQueryBean bean = JsonUtils.objectToPojo(req.getData(), UserChangeQueryBean.class);
		// 校验为空判断,待确定
		UserInfoMapper mapper = factory.getMapper(UserInfoMapper.class);
		List<AccountFlowListBean> list = mapper.accountFlowList(bean);
		Map<String, String> cht = Tools.mapDicByCode(factory, "CHT");//用户状态
		if(list!=null && list.size()>0) {
			for(AccountFlowListBean accountFlowListBean:list) {
				accountFlowListBean.setPayType(cht.get(accountFlowListBean.getPayType()));
			}
		}
		AttachmentDto attachment = new AttachmentDto();
		attachment.setBtlTemplate("AccountFlowListExport.btl");
		attachment.setFileTemplate("AccountFlowListExport.xlsx");
		attachment.setData(list);
		attachment.setFileType("excel");
		attachment.setFilename("账户流水" + CommonUtils.getCurrentDate());
		return attachment;
	}

}
